package main.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import main.dao.BookStorageDB;
import main.view.Main;
import java.io.IOException;
import java.sql.SQLException;

public class BookStorage {
    private String inputBookTitle;
    private String inputPrice;
    private String inputAuthor;
    private String inputType;
    private String inputAmount;
    private String inputMessage;
    @FXML
    private TextField bookName;

    @FXML
    private TextField author;

    @FXML
    private TextField bookPrice;

    @FXML
    private TextField booktype;

    @FXML
    private Button submit;

    @FXML
    private TextArea bookInformation;

    @FXML
    private TextField number;
    @FXML
    private Button setbacks;

    @FXML
    void setbacks(ActionEvent event) throws IOException {
        new Main().initAdminMenu();
    }

    @FXML
    void inputAuthor(KeyEvent event) {

    }

    @FXML
    void inputBookInformation(KeyEvent event) {

    }

    @FXML
    void inputBookName(KeyEvent event) {

    }

    @FXML
    void inputBookNumber(KeyEvent event) {

    }

    @FXML
    void inputBookPrice(KeyEvent event) {

    }

    @FXML
    void inputBookType(KeyEvent event) {

    }

    @FXML
    void submitForm(ActionEvent event) throws SQLException, IOException {
        this.inputBookTitle = bookName.getText();
        this.inputPrice = bookPrice.getText();
        this.inputAuthor = author.getText();
        this.inputType = booktype.getText();
        this.inputAmount = number.getText();
        this.inputMessage = bookInformation.getText();

        new BookStorageDB().enterLibrary(this.inputBookTitle,this.inputPrice,this.inputAuthor,this.inputType,this.inputAmount,this.inputMessage);
        new Main().initAdminMenu();
    }
}
